package com.shop.service.impl;

import com.shop.entity.RolePrivilege;
import com.shop.mapper.RolePrivilegeMapper;
import com.shop.service.RolePrivilegeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service("rolePrivilegeService")
public class RolePrivilegeServiceImpl implements RolePrivilegeService {

    @Autowired
    RolePrivilegeMapper rolePrivilegeMapper;


    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public int add(RolePrivilege rolePrivilege) throws Exception {
        try {
            return rolePrivilegeMapper.add(rolePrivilege);
        } catch (Exception e) {
            throw new Exception("添加异常！");
        }
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public int update(RolePrivilege rolePrivilege) throws Exception {
        try {
            return rolePrivilegeMapper.update(rolePrivilege);
        } catch (Exception e) {
            throw new Exception("更新异常！");
        }
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public int del(RolePrivilege rolePrivilege) throws Exception {
        try {
            return rolePrivilegeMapper.del(rolePrivilege);
        } catch (Exception e) {
            throw new Exception("删除异常！");
        }
    }

    @Override
    public RolePrivilege get(RolePrivilege rolePrivilege) {
        return rolePrivilegeMapper.get(rolePrivilege);
    }

    @Override
    public List<RolePrivilege> getList(RolePrivilege rolePrivilege) {
        return rolePrivilegeMapper.getList(rolePrivilege);
    }
}
